#ifndef __THREAD_H__
#define __THREAD_H__

#include <pthread.h>
#include <iostream>
using namespace std;
class Thread{
public:
  bool r;
  Thread():r(true){}
  virtual void start(){
	 pthread_create(&t, 0, callback, this);
  }
  virtual void stop(){r=false;};
  virtual void join(){void *p; pthread_join(t, &p);};
  virtual void run()=0;
  virtual ~Thread(){};
private:
  pthread_t t;
  static void* callback(void* o){
	  ((Thread*)o)->run();
	  return 0;
  }
  Thread(const Thread &c){}

};

#endif
